package com.hiyee.api.controller.cart;

import com.hiyee.annotation.CurrentCustomer;
import com.hiyee.annotation.JwtVerify;
import com.hiyee.api.config.MicroServiceNameConfig;
import com.hiyee.pojo.auth.LoginCustomer;
import com.hiyee.pojo.bo.CartAddBO;
import com.hiyee.pojo.bo.CartDeleteBO;
import com.hiyee.pojo.bo.CartUpdateBO;
import com.hiyee.response.ResponseJsonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.Valid;
@FeignClient(value = MicroServiceNameConfig.MALL_SERVICE_CART, path = "/rest/api/cart")
public interface CartControllerApi {

    /**
     * 获取购物车商品总数
     *
     * @param LoginCustomer loginCustomer
     * @return ResponseJsonResult
     */
    @GetMapping("/getTotalNum")
    @JwtVerify
    public ResponseJsonResult getTotalNum(@CurrentCustomer LoginCustomer loginCustomer);

    /**
     * 添加购物车
     *
     * @param CartAddBO cartAddBO
     * @param LoginCustomer loginCustomer
     * @return ResponseJsonResult
     */
    @PostMapping("/add")
    @JwtVerify
    public ResponseJsonResult add(@RequestBody @Valid CartAddBO cartAddBO, @CurrentCustomer LoginCustomer loginCustomer);

    /**
     * 获取购物车列表
     *
     * @return
     */
    @GetMapping("/list")
    @JwtVerify
    public ResponseJsonResult getList();

    /**
     * 购物车更新操作
     *
     * @return ResponseJsonResult
     */
    @PostMapping("/update")
    @JwtVerify
    public ResponseJsonResult update(@RequestBody CartUpdateBO cartUpdateBO);

    /**
     * 购物车删除操作
     *
     * @return ResponseJsonResult
     */
    @PostMapping("/delete")
    @JwtVerify
    public ResponseJsonResult delete(@RequestBody CartDeleteBO cartDeleteBO);

    /**
     * 购物车结算
     *
     * @return
     */
    @PostMapping("/checkout")
    @JwtVerify
    public ResponseJsonResult checkout();
}
